package com.ourteam.system.api;

import java.io.File;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ourteam.frame.controller.AbstractServiceController;

@Controller
@CrossOrigin
@RequestMapping("/api/SYSTEM/FILE")
public class SystemFileAPI extends AbstractServiceController {

	@RequestMapping("/getSysFileList")
	@ResponseBody
	public File[] getSysFileList(
			@RequestParam(value = "path") String path,
			HttpServletRequest request, Model model) throws Exception {

		if(StringUtils.isNotBlank(path)){
			File file = new File(path);
			
			return file.listFiles();
		}
		else{
			return File.listRoots();
		}
		
		
		

	}
}
